﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using proRFID_DiemDanh.Chung;

namespace proRFID_DiemDanh.Users
{
    public partial class DangKy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                txt_Username.Focus();

        }

        protected void cmd_dangky_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txt_Username.Text.Trim()))
            {
                lbl_Thongbao.Text = "Nhập đầy đủ thông tin!";
                txt_Username.Text = "";
                txt_Username.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txt_Password.Text.Trim()))
            {
                lbl_Thongbao.Text = "Nhập đầy đủ thông tin!";
                txt_Password.Text = "";
                txt_Password.Focus();
                return;
            }

            DataTable dt = new DataTable();
            dt = mdUsers.User_DangKy(txt_Username.Text.Trim(), txt_Password.Text.Trim());
            string message = dt.Rows[0]["ErrMsg"].ToString();
            lbl_Thongbao.Text = "";
            if (dt.Rows[0]["ErrCode"].ToString() == "0")
                mdMain.OKBox(this, message, "/Default.aspx");
            else
            {
                lbl_Thongbao.Text = message;
            }
        }

        protected void cmd_Huy_Click(object sender, EventArgs e)
        {
            Page.Response.Redirect("/Default.aspx");
        }
    }
}